package com.smalls.newvideotwo.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.VideoView;

import com.smalls.newvideotwo.utils.Constant;

/**
 * @author thearyong
 * @date 2017/3/31
 */

public class FullVideoView extends VideoView {
    private static String TAG = Constant.baddcoolio2tag? Constant.TAGPREFIXSTR + "FullVideoView":"FullVideoView";
    public FullVideoView(Context context) {
        super(context);
    }

    public FullVideoView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public FullVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        // super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        //获取控件的宽度，手动进行测量
        //获取被父控件约束的宽度或者是高度
        //参数1：默认控件的宽/高
        //参数2：父控件约束的宽/高
        int width = getDefaultSize(0, widthMeasureSpec);
        int height = getDefaultSize(0, heightMeasureSpec);
        Log.i(TAG,"onMeasure widthMeasureSpec="+widthMeasureSpec+" heightMeasureSpec="+heightMeasureSpec+" w="+width+" h="+height);
        this.setMeasuredDimension(width, height);
    }

    @Override
    public void resume() {
        setFocusable(false);
        super.resume();
    }

}
